package com.shunwang.test.spring;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import com.shunwang.errors.engine.core.ErrorsHandler;
import com.shunwang.errors.engine.exception.BussException;

public class LoggerAdvice implements MethodInterceptor {

	private ErrorsHandler logger ;
	
	public ErrorsHandler getLogger() {
		return logger;
	}

	public void setLogger(ErrorsHandler logger) {
		this.logger = logger;
	}

	public Object invoke(MethodInvocation invok) throws Throwable {
		try{
			return invok.proceed();
		}catch(BussException e){
			logger.doHandler(e, invok.getArguments());
		}
		return null;
	}

}
